package com.flyee.viewer
{
	import com.flyee.utils.GenerateIDTool;
	
	import flash.display.DisplayObject;
	import flash.display.SimpleButton;
	import flash.display.Sprite;
	
	public class ImageButtonViewer extends Sprite implements Destroy
	{
		public var vid:String = GenerateIDTool.generateID();
		protected var button:SimpleButton = null;
		public function ImageButtonViewer()
		{
			super();
			button = new SimpleButton();
			disabled = false;
			//button.opaqueBackground
			this.addChild(button);
		}
		/**
		 * 设置按钮的显示图标 
		 * @param state
		 * 
		 */		
		public function set state(state:DisplayObject):void{
			button.upState =state;
			button.downState = state;
			button.overState = state;
			button.hitTestState = state;
			this.width = button.width;
			this.height = button.height;
		}
		/**
		 * 设置按钮是否可用 
		 * @param dis
		 * 
		 */		
		public function set disabled(dis:Boolean):void{
			if(dis){
				this.button.useHandCursor = false;
				this.button.trackAsMenu = false;
				this.disabled = true;
			}else{
				this.button.useHandCursor = true;
				this.button.trackAsMenu = true;
				//this.disabled = false;
			}
		}
		
		public function setSizeWH(w:int,h:int):void{
			this.width = w;
			this.height = h;
		}
		
		public function setLocation(x:Number,y:Number):void{
			this.x = x;
			this.y = y;
		}
		
		public function dispose():void{
			button = null;
		}
	}
}